import Vue from "vue"
import App from "./App"
import router from "./router/index"
import store from "./store/index"

import 'remixicon/fonts/remixicon.css'

import 'element-ui/lib/theme-chalk/index.css';
import ElementUI from 'element-ui'
Vue.use(ElementUI);

import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
    ak: 'kpXY4Qtw6oz83cBd59Rv0hoNG0NNsaxp',
});

// axios
import { axios } from "./api/index"
Vue.prototype.$axios = axios;

import "./assets/style/reset.css"

Vue.config.productionTip = false;

//重写confirm
window.confirm = function (name) {
    var iframe = document.createElement('IFRAME');
    iframe.style.display = 'none';
    iframe.setAttribute('src','');
    document.documentElement.appendChild(iframe);
    var a=window.frames[0].window.confirm(name);
    iframe.parentNode.removeChild(iframe);
    return a
};

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
      document.title = to.meta.title
  }
  if(to.path!='/' && !localStorage.token){
      next('/')
  }else{
      next()
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
